package com.huayue.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.huayue.entity.DepotOutOrderDetails;
import com.huayue.util.PageHelper;
import com.mysql.DBHelper;

/**
 * 出库详情
 */
@Component
public class DepotOutOrderDetailsDao implements BaseDao<DepotOutOrderDetails> {

    @Override
    public int insert(DepotOutOrderDetails entity) {
        return DBHelper.executeUpdate(
            "insert into depot_out_order_details (depot_out_order_id,product_id,number,remark)values((select max(id) from depot_out_order),?,?,?)",
            entity.getProductId(), entity.getNumber(), entity.getRemark());
    }

    @Override
    public int update(DepotOutOrderDetails entity) {
        return 0;
    }

    @Override
    public int delete(DepotOutOrderDetails entity) {
        return 0;
    }

    @Override
    public List<Map<String, Object>> findAll(Object... obj) {
        return null;
    }

    @Override
    public List<Map<String, Object>> findPage(PageHelper page, Object... obj) {
        return null;
    }

    @Override
    public Map<String, Object> findOne(DepotOutOrderDetails entity) {
        return null;
    }

    @Override
    public int count(Object... obj) {
        return 0;
    }

    public List<Map<String, Object>> findDetails(String id) {
        return DBHelper.executeQuery(
            "select p.id, p.name,p.product_number,o.number,real_number,o.remark from depot_out_order_details o LEFT JOIN product p on o.product_id = p.id LEFT JOIN depot d on d.product_id = p.id where o.depot_out_order_id=?",
            id);
    }

}
